package server.mapper;

import org.dom4j.Element;

import java.util.List;

public  class Host {
    private  List<Element> elementList ;
    private  String name;
    private  String appBase;
    private  Context[] contexts;

    public List<Element> getElementList() {
        return elementList;
    }

    public void setElementList(List<Element> elementList) {
        this.elementList = elementList;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAppBase() {
        return appBase;
    }

    public void setAppBase(String appBase) {
        this.appBase = appBase;
    }

    public Context[] getContexts() {
        return contexts;
    }

    public void setContexts(Context[] contexts) {
        this.contexts = contexts;
    }

    public Host(List<Element> elementList) {
        /**
         *   <Service>
         *         <Connector prot="8080">
         *             <Engine>
         *                 <Host name="localhost" appBase="D:/lucasMiniCat/webapps/"></Host>
         *             </Engine>
         *         </Connector>
         *     </Service>
         */
        this.elementList = elementList;
        for (Element element : elementList) {
            List<Element> hostList = element.selectNodes("//Host");
            for (Element o : hostList) {
                String name = o.attributeValue("name");
                String appBase = o.attributeValue("appBase");
                this.name =name;
                this.appBase=appBase;
            }
        }

    }
}
